package com.clps.digital.dao.impl;

import cn.hutool.core.util.ObjectUtil;
import com.clps.digital.dao.NotificationDao;
import com.clps.digital.model.entity.Notification;
import com.clps.myssm.basedao.BaseDAO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: Chase
 * @date: 2024/9/3 10:15
 * @Version: 1.0
 * @description:
 */

public class NotificationDaoImpl extends BaseDAO<Notification> implements NotificationDao {

    /**
     * 获取通知标题列表
     * @return
     */
    @Override
    public List<String> getNotificationTitle() {
        List<Notification> notificationList = selectList("SELECT * from dbo.[notification]");
        if (ObjectUtil.isEmpty(notificationList)) {
            return null;
        }
        return notificationList.stream()
                .map(notification -> notification.getTitle())
                .collect(Collectors.toList());
    }

    /**
     * 获取通知详情列表
     * @return
     */
    @Override
    public List<Notification> getNotificationList() {
        return selectList("SELECT * from dbo.[notification]");
    }

    /**
     * 获取单个通知详情
     * @param id
     * @return
     */
    @Override
    public Notification getNotification(Long id) {
        return selectOne("SELECT * from dbo.[notification] where [id] = ?", id);
    }
}
